package com.example.mealplanner;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainUIActivity extends Activity {

	public static final String PREFS_NAME = "MealPlannerCredentials";
	private static final String PREF_USERNAME = "username";
	
	private Button cuisineButton;
	private Button waitlistButton;
	private Button profileButton;
	private TextView welcomeMessage;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main_ui);
		
		cuisineButton = (Button) findViewById(R.id.cuisine_button);
		waitlistButton = (Button) findViewById(R.id.waitlist_button);
		profileButton = (Button) findViewById(R.id.profile_button);
		welcomeMessage = (TextView) findViewById(R.id.welcome_mainui);
		
		SharedPreferences pref = getSharedPreferences(PREFS_NAME,MODE_PRIVATE);   
		String userName = pref.getString(PREF_USERNAME, null);
		welcomeMessage.setText(userName + ", welcome back!");
		
		
		cuisineButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				enterMenu();
			}
		});
		
		waitlistButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				enterWaitlist();
			}
		});
		
		profileButton.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				enterProfile();
			}
		});
		
	}

	protected void enterProfile() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(this, ProfileActivity.class);
		startActivity(intent);
	}

	protected void enterWaitlist() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(this, WaitingListActivity.class);
		startActivity(intent);
	}

	protected void enterMenu() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(this, MenuActivity.class);
		startActivity(intent);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main_ui, menu);
		return true;
	}

}
